package com.fudan.biz.data.dao;

import java.util.List;
import java.util.Map;

import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import com.fudan.biz.data.entity.BigDataSource;
import com.fudan.framework.base.BaseDao;

@Repository
public interface BigDataSourceDao extends BaseDao<BigDataSource>{

	@Query(nativeQuery=true,value="select d.*,dw.name dwName,dw.id dwId from t_datasource d left join t_data_warehouse dw on d.dw_id=dw.id where d.discard=0 limit ?1,?2")
	public List<Map<String,Object>> getInfoList(int page,int size);

	@Query(nativeQuery=true,value="select count(*) from t_datasource d left join t_data_warehouse dw on d.dw_id=dw.id where d.discard=0")
	public Long countInfoList();

	@Query(nativeQuery=true,value="select d.*,dw.name dwName,dw.id dwId from t_datasource d left join t_data_warehouse dw on d.dw_id=dw.id where d.discard=0 and d.name like %?1% limit ?2,?3")
	public List<Map<String,Object>> getInfoList(String query,int page,int size);

	@Query(nativeQuery=true,value="select count(*) from t_datasource d left join t_data_warehouse dw on d.dw_id=dw.id where d.discard=0 and d.name like %?1%")
	public Long countInfoList(String query);

	@Query(nativeQuery=true,value="select d.*,dw.name dwName,dw.id dwId from t_datasource d left join t_data_warehouse dw on d.dw_id=dw.id where d.discard=0 and d.id=?1")
	public Map<String,Object> getInfo(String id);
}
